CC = gcc -I..
CXX = g++ -I..
#OPT = -g
OPT = -g -Wall -O3

# Determine the OS we're running on
OSTYPE := $(shell uname)

#
# LINUX SECTION
#
ifneq (,$(findstring Linux,$(OSTYPE)))
DL = -ldl
DLFLAGS = -fpic -shared -Wl,--export-dynamic
endif

#
# MAC OSX SECTION
#
ifneq (,$(findstring Darwin,$(OSTYPE)))
DL = -ldl
DLFLAGS = -fPIC -bundle -undefined dynamic_lookup
endif

#
# CYGWIN SECTION
#
ifneq (,$(findstring cygwin,$(OSTYPE))$(findstring CYGWIN,$(OSTYPE)))
DL =
DLFLAGS = -shared -Wl,--export-dynamic
endif


DYN_OBJS = ./pancake14_0.so  ./pancake14_6.so ./pancake14_7.so \
	   ./pancake14_8.so  ./pancake14_9.so ./pancake14_10.so \
	   ./pancake14_11.so ./pancake14_12.so

all: $(DYN_OBJS)

%.c: %.psvn ../psvn2c ../psvn2c_common.c
	cd .. && ./psvn2c --name=$(*F) --backwards_moves < pancake14/$< > pancake14/$@

%.so: %.c ../psvn_game_so.h
	$(CC) $(OPT) $(DLFLAGS) $< $(DL) -o $@

clean:
	rm *.so
